Pressidian
花园入口
笔记
项目
关于
实验室
GitHub
花园入口
笔记
项目
关于
实验室
GitHub

KNOWLEDGE PATHS

笔记库
当前位置
笔记库/前端/三件套/样式/CSS/MDN文档/1 基础样式/7 溢出

Test your skills: Overflow

10 分钟阅读 · Note

目录树 578 篇

                  • 溢出的内容
                  • Challenge: Sizing and decorating a content panel
                  • Test your skills: Overflow
          • tailwindCSS
      • 前端技术栈
    • 笔记目录
    • CLAUDE.md
    • Vue 组件与 Render 函数

关联笔记 6

↗溢出的内容同一路径↗Challenge: Sizing and decorating a content panel同一路径↗背景与边框共同主题↗测试你的技能:CSS 样式基础共同主题↗层叠、优先级与继承共同主题↗调试 CSS共同主题
  • Test your skills: Overflow

Test your skills: Overflow

  • Previous
  • Overview: CSS styling basics
  • Next

The aim of this skill test is to help you assess whether you understand overflow in CSS and how to manage it.

Note: To get help, read our Test your skills usage guide. You can also reach out to us using one of our communication channels.

In this article

  • Overflow 1
  • Overflow 2

[Scrimba

Frontend development career path by ScrimbaA structured program to help you go from beginner to job-ready.Get started

](https://developer.mozilla.org/pong/click?code=aHR0cHM6Ly9zcnYuYnV5c2VsbGFkcy5jb20vYWRzL2NsaWNrL3gvR1RORDQyN1VDWUJJS0szTkY2U0xZS1FVQ0FTSTQySk1DNllJUFozSkNBU0k1SzdFQzZBRDYyN0tDNjdJUDJRWUZUU0lQS1FZQ0VZSVAySjdDV1NEUEtRRUhFWUk1MjdOQ1lZSVQ1M0VDVE5DWUJaNTJL.aiN2mHQNNhpVbpA2Frtm7QO4z0DFrvm05ypcfGbAN%2FU%3D&version=2)Ad

Overflow 1

In this task, the content is overflowing the box because it has a fixed height.

To complete the task:

  1. Update the CSS so that the box height is maintained and scrollbars appear only when there is enough text to cause an overflow.
  2. Test your solution by removing some text from the HTML and checking that no scrollbar appears when there is only a small amount of text.

The starting point of the task looks like this:

Play

Here's the underlying code for this starting point:

htmlCopyPlay

<div class="box">
  <p>
    Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion
    daikon amaranth tatsoi tomatillo melon azuki bean garlic.
  </p>

  <p>
    Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette
    tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato.
    Dandelion cucumber earthnut pea peanut soko zucchini.
  </p>
</div>

cssCopyPlay

body {
  font: 1.2em / 1.5 sans-serif;
}

.box {
  border: 5px solid black;
  padding: 1em;
  height: 200px;
  width: 300px;
}

The updated styling should look like this:

Play

Click here to show the solution

You should add overflow: auto so that the box will only gain scrollbars when the content is too large:

Overflow 2

In this task, there is an image in the box that is bigger than the dimensions of the box so that it overflows visibly. Update the CSS so that any image outside of the box is hidden.

The starting point of the task looks like this:

Play

Here's the underlying code for this starting point:

htmlCopyPlay

<div class="box">
  <img
    alt="flowers"
    src="https://mdn.github.io/shared-assets/images/examples/flowers.jpg" />
</div>

cssCopyPlay

body {
  font: 1.2em / 1.5 sans-serif;
}
.box {
  border: 5px solid black;
  height: 200px;
  width: 300px;
}

The updated styling should look like this:

Play

Click here to show the solution

You should add overflow: hidden to the .box selector:

  • Previous
  • Overview: CSS styling basics
  • Next

Help improve MDN

Was this page helpful to you?

YesNo

Learn how to contribute

This page was last modified on Feb 3, 2026 by MDN contributors.

View this page on GitHub • Report a problem with this content

Filter sidebar

  1. Learn web development

  2. MDN curriculum

  3. Getting started modules

  4. Environment setup

  5. Your first website

  6. Web standards

  7. Soft skills

  8. Core modules

  9. Structuring content with HTML

  10. CSS styling basics

    1. What is CSS?
    2. CSS getting started
    3. Challenge: Biography page
    4. Basic selectors
    5. Attribute selectors
    6. Pseudo-classes and elements
    7. Combinators
    8. Test: Selectors
    9. Box model
    10. Test: Box model
    11. Handling conflicts
    12. Test: Cascade
    13. Challenge: Fixing blog styles
    14. Values and units
    15. Test: Values and units
    16. Sizing
    17. Test: Sizing
    18. Backgrounds and borders
    19. Test: Backgrounds and borders
    20. Overflow
    21. Test: Overflow
    22. Challenge: Sizing and decorating
    23. Images, media, forms
    24. Test: Images and forms
    25. Styling tables
    26. Challenge: Styling color scheme search
    27. Debugging CSS
    28. Test: Styling basics tests index
    29. Additional tutorials
  11. CSS text styling

  12. CSS layout

  13. Dynamic scripting with JavaScript

  14. JavaScript frameworks and libraries

  15. Accessibility

  16. Design for developers

  17. Version control

  18. Extension modules

  19. Advanced JavaScript objects

  20. Client-side web APIs

  21. Asynchronous JavaScript

  22. Web forms

  23. Understanding client-side tools

  24. Server-side websites

  25. Web performance

  26. Testing

  27. Further resources

  28. How to solve common problems

  29. About

  30. Resources for educators

  31. Changelog

MongoDB AtlasAd

Your blueprint for a better internet.

MDN

  • About
  • Blog
  • Mozilla careers
  • Advertise with us
  • MDN Plus
  • Product help

Contribute

  • MDN Community
  • Community resources
  • Writing guidelines
  • MDN Discord
  • MDN on GitHub

Developers

  • Web technologies
  • Learn web development
  • Guides
  • Tutorials
  • Glossary
  • Hacks blog

  • Website Privacy Notice
  • Telemetry Settings
  • Legal
  • Community Participation Guidelines

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.